#ifndef _GAME_CPP
#define _GAME_CPP

#include "Renderer.cpp"
class Game
{
private:
    /* data */
    //handle 句柄
    //both params must be set together
    HANDLE m_Handle;
    CONSOLE_CURSOR_INFO myCur;
    Renderer mRenderer;
    bool m_Start = false;

    COORD posBegin = {0, 0};

public:
    Game(/* args */);
    ~Game();
    void Start()
    {
        // windows console settings
        SetConsoleCursorInfo(m_Handle, &myCur);
        m_Start = true;
        Renderer::Rect ret = {2, 4, 0, 0};

        /*
        the very important GAME MAIN LOOP
        */
        while (m_Start)
        {

            /*
            to generate a frame should do these operations
            to get the latest frame
            */
            ProcessInput();
            Update(ret);
            GenerateOutput(ret);
        }
    }

    void Update(Renderer::Rect &rect)
    {

        rect.x += 1;
    }

    void ProcessInput()
    {
        // std::cout << "process input" << std::endl;
    }

    void GenerateOutput(Renderer::Rect rect)
    {
        mRenderer.Clear();
        mRenderer.DrawRect(rect);
        mRenderer.Present();
        SetConsoleCursorPosition(m_Handle, posBegin);
    }
};

Game::Game(/* args */)
{

    m_Handle = GetStdHandle(STD_OUTPUT_HANDLE);
    myCur.bVisible = false;
    myCur.dwSize = 1;
}

Game::~Game()
{
}

#endif